FindFolder
FindFolder Find a specified folder
#include <Folders.h> Finder Interface
OSErr FindFolder ( vRefNum, folderType, createFolder, foundVRefNum,
foundDirID);
short vRefNum ; volume reference number
OSType folderType; folder type for volume
Boolean createFolder; kCreateFolder or kDontCreateFolder
short * foundVRefNum; volume reference number for folder found
long * foundDirID; directory ID of folder found
Returns 0 = no error
The FindFolder function returns the volume reference number and
directory ID of a specified folder type for a specified volume.You specify a
volume reference number (or the constant kOnSystemDisk for the boot disk)
in the vRefNum parameter. In the folderType parameter, specify a constant
from the list below. Use the constant kCreateFolder in the createFolder
parameter to tell FindFolder to create a directory if it does not already exist;
otherwise, use the constant kDontCreateFolder. FindFolder puts the results
in foundVRefNum and foundDirID.
Folder
Directory type Constant
Apple Menu Items 'amnu' kAppleMenuFolderType
Control Panels 'ctrl' kControlPanelFolderType
Desktop Folder 'desk' kDesktopFolderType
Extensions 'extn' kExtensionFolderType
P references 'pref' kP referencesFolderType
PrintMonitor Documents 'prnt' kPrintMonitorDocsFolderType
Shared, network Trash 'empt' kWhereToEmptyTrashFolderType
Single-user Trash 'trsh' kTrashFolderType
Startup Items 'strt' kStartupFolderType
System Folder 'macs' kSystemFolderType
Temporary Items 'temp' kTemporaryFolderType
Note: The Finder identifies the subdirectories of the
System Folder, and their folder types, in a resource of type 'fld#'
located in the System file. Do not modify or rely on the contents of the
'fld#' resource in the System file; use only the FindFolder function
and these constants to find the appropriate directories.
Use the kTrashFolderType constant to locate the current user's Trash
directory for a given volume-even one located on a file server. On a file
server, you can use the kWhereToEmptyTrashFolderType constant to locate the
parent directory of all logged-on users' Trash sub directories.
In calls to FindFolder, you can also use these three constants:
kOnSystemDisk use vRefNum for the boot disk
kCreateFolder create folder if it does not exist
kDontCreateFolder do not create folder
Remember that the specified folder used for a given volume might be located
on a different volume in the future; therefore, do not assume the volume that
you specify in vRefNum and the volume returned in foundVRefNum will be the
same.
Note: Directories inside the System Folder are created only if the
System Folder directory exists. FindFolder will not create a
System Folder directory even if the kCreateFolder constant is
specified.
FindFolder is only available under System 7. However, if you are using
THINK C 5.0 or later or the MPW Development System 3.2 or later, glue is
provided that allows you to call FindFolder under System 6 as well as System
7. The glue will return the vRefNum and dirID of the System Folder if any of
the following selectors are passed:
kSystemFolderType
kTemporaryFolderType
kP referencesFolderType
kExtensionFolderType
kControlPanelFolderType
kAppleMenuFolderType
kStartupFolderType
kPrintMonitorDocsFolderType
All other selectors will result in FindFolder returning a paramErr since
the other folder types are not supported under System 6.
The FindFolder function returns a nonzero result code if the folder is not
found, and it can also return other file system errors reported by the
File Manager or Memory Manager.
Returns: an Error code. It will be one of the following:
noErr (0) No error
fnfErr (-43) Type not found in 'fld#' resource, or disk does not
have System Folder support or System Folder in volume
header, or disk does not have desktop database support
for Desktop Folder-in all cases, folder not found
dupFNErr (-48) File found instead of folder
paramErr (-50) Error in user parameter list